package maa.entity;

import java.sql.Date;
import java.util.List;
import java.util.UUID;

public class User {

    private UUID uuid;
    private String email;
    private String password;
    private String name;
    private String surname;
    private Date birthdate;
    private Gender gender;
    private Role role;
    private List<Course> courseList;

    public void setUuid(UUID uuid) {
        this.uuid = uuid;
    }

    public User() {
        this.uuid = UUID.randomUUID();
    }

    public UUID getUuid() {
        return uuid;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        User user = (User) o;

        if (!birthdate.equals(user.birthdate)) return false;
        if (courseList != null ? !courseList.equals(user.courseList) : user.courseList != null) return false;
        if (!email.equals(user.email)) return false;
        if (gender != user.gender) return false;
        if (!name.equals(user.name)) return false;
        if (!password.equals(user.password)) return false;
        if (role != user.role) return false;
        if (!surname.equals(user.surname)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = email.hashCode();
        result = 31 * result + password.hashCode();
        result = 31 * result + name.hashCode();
        result = 31 * result + surname.hashCode();
        result = 31 * result + birthdate.hashCode();
        result = 31 * result + gender.hashCode();
        result = 31 * result + role.hashCode();
        result = 31 * result + (courseList != null ? courseList.hashCode() : 0);
        return result;
    }

    public User(String email, String password, String name, String surname, Date birthdate, Gender gender, Role role) {
        this.email = email;
        this.password = password;
        this.name = name;
        this.surname = surname;
        this.birthdate = birthdate;
        this.gender = gender;
        this.role = role;
        this.uuid = UUID.randomUUID();
    }

    public List<Course> getCourseList() {
        return courseList;
    }

    public void setCourseList(List<Course> courseList) {
        this.courseList = courseList;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public Date getBirthdate() {
        return birthdate;
    }

    public void setBirthdate(Date birthdate) {
        this.birthdate = birthdate;
    }

    public Gender getGender() {
        return gender;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
    }

    public User(String email, String password) {
        this.email = email;
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "User " + name+ " " + surname;
    }
}
